export default {
	toEvaluate(id) {
		uni.navigateTo({
			url: '/pages/my/evaluate?id=' + id
		})
	},
	confirmShipment(id) {
		uni.navigateTo({
			url: '/pages/my/delivery?id=' + id
		})
		// let that = this
		// that.$toast.confirm({
		// 	content: `是否确认发货？`,
		// 	confirmText: '确认',
		// 	callback: result => {
		// 		if (result) {
		// 			that.$httpRequest.request({
		// 				that: that,
		// 				url: 'wechat/confirmShipping',
		// 				method: 'post',
		// 				params: {
		// 					id
		// 				},
		// 				success: res => {
		// 					if (res.code === that.$httpConfig.SUCCESS_CODE) {
		// 						that.getPageData()
		// 					}
		// 				}
		// 			})
		// 		}
		// 	}
		// })
	},
	confirmReceive(id) {
		let that = this
		that.$toast.confirm({
			content: `是否确认收货？`,
			confirmText: '确认',
			callback: result => {
				if (result) {
					that.$httpRequest.request({
						that: that,
						url: 'wechat/confirmReceive',
						method: 'post',
						params: {
							id
						},
						success: res => {
							if (res.code === that.$httpConfig.SUCCESS_CODE) {
								this.page = 1
								this.list = []
								this.getPageList()
							}
						}
					})
				}
			}
		})
	},
	submit() {
		let that = this
		that.$httpRequest.request({
			that: that,
			method: 'post',
			url: 'wechat/createProductOrder',
			params: that.formData,
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					// that.$toast.msg(res.message, {
					// 	icon: 1
					// })
				} else {
					that.$toast.msg(res.message, {
						icon: 1
					})
				}
			}
		})
	},
	getPageData() {
		let that = this
		that.$httpRequest.request({
			that: that,
			method: 'get',
			url: 'wechat/getOrderDetail',
			params: {
				id: that.id
			},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.detail = res.data
				} else {
					that.$toast.msg(res.message, {
						icon: 1
					})
				}
			}
		})
	},
	wechatPay(id) {
		let that = this
		this.loading = true;
		that.$httpRequest.request({
			that: that,
			url: 'wechat/orderPay',
			params: {
				id
			},
			success: res => {
				that.loading = false
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					// that.upSuccessPay(true)
					let data = res.data
					uni.requestPayment({
						timeStamp: data.timeStamp,
						nonceStr: data.nonceStr,
						package: data.package,
						signType: data.signType,
						paySign: data.paySign,
						success: res => {
							that.$toast.alert({
								content: '支付成功！',
								callback: result => {
									if (result.confirm) {
										uni.navigateBack({
											delta: 1
										})
									}
								}
							})
						}
					})
				} else {
					that.$toast.alert({
						content: res.msg,
						callback: result => {

						}
					})
				}
			}
		})

	},
	getStatusStr(e) {
		let str = ''
		switch (e) {
			case 1:
				str = '待付款'
				break;
			case 2:
				str = '待发货'
				break;
			case 3:
				str = '待收货'
				break;
			case 4:
				str = '待评价'
				break;
			case 5:
				str = '退款中'
				break;
			case 6:
				str = '已退款'
				break;
			case 7:
				str = '已完成'
				break;
			default:
				break;
		}
		return str
	},




}